<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const str = "123aaaabc45678efg12222";

      console.log(str.match(/\d\d\d\d/g));
      console.log(str.match(/\d{4}/g));
      console.log(str.match(/a{4}/g)); // aaaa
      console.log(str.match(/2{4}/g)); // 2222
      console.log(str.match(/\d{2,4}/g)); //\d\d,\d\d\d,\d\d\d\d
      console.log(str.match(/\d{2,}/g)); // 2-无穷
    </script>
  </body>
</html>
